package com.seadragon.app.ksr.dao.jpa;

import java.util.List;

import javax.persistence.Query;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

import com.seadragon.app.ksr.dao.ZipDao;
import com.seadragon.app.ksr.model.tiger.Zip;

@Repository("zipDao")
@SuppressWarnings("unchecked")
public class ZipDaoJpaImpl extends AbstractJpaDao implements ZipDao {
	private static Logger logger = LoggerFactory.getLogger(ZipDaoJpaImpl.class);


	@Override
	public List<Zip> findAdjacentZips(String zipCode) {
		logger.info("Entering ... ");
		Query q = entityManager.createNamedQuery("findAdjacentZips").setParameter("zipCode", zipCode);
		q.setHint("org.hibernate.readOnly",true);
		logger.info("Leaving ...");
		return (List<Zip>)q.getResultList();
	}
}
